<!DOCTYPE html>
<html lang="en">
<head>
    {include file="common/meta" /}

    <style type="text/css">
        body {
            color:#999;
        }
        a {
            color:#fff;
        }
        #header {
            background-color: #2a3238;
            font-size: 14px;
        }
        #logo {
            height: 55px;
        }
        #navbar-collapse-menu {
            padding: 2px 20px 0;
        }
        .page-heading {
            padding: 10px 0;
            border-bottom: 2px solid #18bc9c;
            text-align: center;
        }
        .login-screen {
            max-width:400px;
            padding:0;
            margin:50px auto 0;
        }
        .login-screen .well {
            border-radius: 3px;
            -webkit-box-shadow: 0 0 10px rgba(0, 0, 0, 0.1);
            box-shadow: 0 0 10px rgba(0, 0, 0, 0.1);
            background: rgba(255,255,255, 0.2);
        }
        .login-screen .copyright {
            text-align: center;
        }

        @media(max-width:767px) {
            .login-screen {
                padding:0 20px;
            }
        }

        #register-form {
            margin-top:20px;
        }
        #register-form .input-group {
            margin-bottom:15px;
        }
        #register-form .form-group {
            margin-top: 15px;
        }

    </style>
    <style>
        #embed-captcha {
            max-width: 300px;
            margin: 0 auto;
        }
        .show {
            display: block;
        }
        .hide {
            display: none;
        }
    </style>
</head>
<body>
<nav id="header" class="navbar navbar-inverse navbar-static-top">
    <div class="container-fluid">
        <div class="navbar-header">
             <button type="button" class="navbar-toggle collapsed" data-toggle="collapse" data-target="#navbar-collapse-menu">
                <i class="fa fa-bars"></i>
            </button>
            <a href=""><img id="logo" src="/assets/img/logo.png"></a>
        </div>

        <div class="collapse navbar-collapse" id="navbar-collapse-menu">
            <ul class="nav navbar-nav navbar-right">
                <li><a href="http://link.hdussta.cn/">首页</a></li>
                <li><a href="#">文档</a></li>
                <li><a href="http://link.hdussta.cn/admin/index/login.html">登录</a></li>
            </ul>
        </div>
        <!-- /.navbar-collapse -->
    </div>
    <!-- /.container-fluid -->
</nav>

<div class="page-heading">
    <h3>注册云平台账号</h3>
</div>

<div class="container">
    <div class="login-screen">
        <div class="well">
            <div class="register-form">
                <form method="post" id="register-form" onsubmit="return false;">
                    <div id="errtips" class="hide"></div>
                    <div class="input-group">
                        <div class="input-group-addon"><span class="glyphicon glyphicon-user" aria-hidden="true"></span></div>
                        <input type="text" class="form-control" id="pd-form-username" placeholder="{:__('Username')}" name="username" autocomplete="off" value="" data-rule="{:__('Username')}:required;username" />
                    </div>

                    <div class="input-group">
                        <div class="input-group-addon"><span class="glyphicon glyphicon-lock" aria-hidden="true"></span></div>
                        <input type="password" class="form-control" id="pd-form-password" placeholder="{:__('Password')}" name="password" autocomplete="off" value="" data-rule="{:__('Password')}:required;password" />
                    </div>

                    <div class="input-group">
                        <div class="input-group-addon"><span class="glyphicon glyphicon-lock" aria-hidden="true"></span></div>
                        <input type="text" class="form-control" id="pd-form-email" placeholder="{:__('email')}" name="email" autocomplete="off" value="" data-rule="{:__('email')}:required;email" />
                    </div>

                    <div id="embed-captcha"></div>
                    <p id="wait" class="show">正在加载验证码......</p>
                    <p id="notice" class="hide">请先完成验证</p>

                    <div class="form-group">
                        <button class="btn btn-success btn-lg btn-block" onclick="submitRegister()">注册</button>
                    </div>
                </form>
            </div>
        </div>
        <p class="copyright"><a href="http://www.hdussta.cn/">Developed By SSTA</a></p>
    </div>
</div>


<script src="../../assets/js/gt.js"></script>
<script src="http://apps.bdimg.com/libs/jquery/1.9.1/jquery.js"></script>
<script>
    var submitRegister=function () {
        $.ajax({
            type: "POST",
            url:"",
            data:$('#register-form').serialize(),
            async: false,
            datatype:"json",
            error: function(request) {
                alert("Connection error");
            },
            success: function(data) {
                if(data.status!=-1)
                     Toastr.success(data.info);
                else
                    Toastr.error(data.info);
            }
        });
    };
    var handlerEmbed = function (captchaObj) {
        $("#embed-submit").click(function (e) {
            var validate = captchaObj.getValidate();
            if (!validate) {
                $("#notice")[0].className = "show";
                setTimeout(function () {
                    $("#notice")[0].className = "hide";
                }, 2000);
                e.preventDefault();
            }
        });
        // 将验证码加到id为captcha的元素里，同时会有三个input的值：geetest_challenge, geetest_validate, geetest_seccode
        captchaObj.appendTo("#embed-captcha");
        captchaObj.onReady(function () {
            $("#wait")[0].className = "hide";
        });
        // 更多接口参考：http://www.geetest.com/install/sections/idx-client-sdk.html
    };
    $.ajax({
        // 获取id，challenge，success（是否启用failback）
        url: "StartCaptchaServlet?t=" + (new Date()).getTime(), // 加随机数防止缓存
        type: "get",
        dataType: "json",
        success: function (data) {
            console.log(data);
            // 使用initGeetest接口
            // 参数1：配置参数
            // 参数2：回调，回调的第一个参数验证码对象，之后可以使用它做appendTo之类的事件
            initGeetest({
                gt: data.gt,
                challenge: data.challenge,
                new_captcha: data.new_captcha,
                product: "embed", // 产品形式，包括：float，embed，popup。注意只对PC版验证码有效
                offline: !data.success // 表示用户后台检测极验服务器是否宕机，一般不需要关注
                // 更多配置参数请参见：http://www.geetest.com/install/sections/idx-client-sdk.html#config
            }, handlerEmbed);
        }
    });
</script>
{include file="common/script" /}
</body>
</html>
